{% extends 'base/base.html' %}

{% block title %}文旅机构仪表盘{% endblock %}

{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/culture.css' %}">
{% endblock %}

{% block sidebar %}
<div class="sidebar-sticky pt-3">
    <ul class="nav flex-column">
        <li class="nav-item">
            <a class="nav-link active" href="{% url 'accounts:culture_dashboard' %}">
                <i class="fas fa-tachometer-alt me-2"></i>仪表盘
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="{% url 'accounts:spot_list' %}">
                <i class="fas fa-map-marked-alt me-2"></i>景点管理
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="{% url 'accounts:add_spot' %}">
                <i class="fas fa-plus-circle me-2"></i>添加景点
            </a>
        </li>
    </ul>
</div>
{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">文旅机构仪表盘</h1>
</div>

<div class="row mb-4">
    <div class="col-md-4">
        <div class="card text-white bg-primary mb-3">
            <div class="card-body">
                <h5 class="card-title">景点总数</h5>
                <p class="card-text display-4">{{ total_spots }}</p>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card text-white bg-success mb-3">
            <div class="card-body">
                <h5 class="card-title">已通过</h5>
                <p class="card-text display-4">{{ approved_spots }}</p>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card text-white bg-warning mb-3">
            <div class="card-body">
                <h5 class="card-title">待审核</h5>
                <p class="card-text display-4">{{ pending_spots }}</p>
            </div>
        </div>
    </div>
</div>

<div class="card">
    <div class="card-header">
        <h5>最新景点</h5>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>景点名称</th>
                        <th>状态</th>
                        <th>提交时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for spot in latest_spots %}
                    <tr>
                        <td>{{ spot.name }}</td>
                        <td>
                            {% if spot.status == 'approved' %}
                            <span class="badge bg-success">已通过</span>
                            {% elif spot.status == 'pending' %}
                            <span class="badge bg-warning">待审核</span>
                            {% else %}
                            <span class="badge bg-danger">已拒绝</span>
                            {% endif %}
                        </td>
                        <td>{{ spot.created_at|date:"Y-m-d H:i" }}</td>
                        <td>
                            <a href="{% url 'accounts:edit_spot' spot.id %}" class="btn btn-sm btn-primary">编辑</a>
                        </td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="4" class="text-center">暂无景点数据</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script src="{% static 'js/culture.js' %}"></script>
{% endblock %}